﻿package mortal.game.view.copy.worldBoss.WorldBossAllot
{
    import Message.Client.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.mail.view.*;
    import mortal.mvc.core.*;

    public class WorldBossAllotCell extends GCellRenderer
    {
        private var _selectFilter:ScaleBitmap;
        private var _rewardItemName:GTextFiled;
        private var _rewardItem:MailAttachItem;
        private var _needNumText:GTextFiled;
        private var _btn:GLoadingButton;
        private var _leftTime:SecTimerView;
        private var _bmpSelected:GImageBitmap;
        private var _tipCanChange:GTextFiled;
        private var _diceLeftTime:SecTimerView;
        private var _diceState:GTextFiled;
        private var _youSelected:GTextFiled;
        private var _youAreTheWinner:GTextFiled;
        private var _getterName:GTextFiled;
        private var _getterDiceNum:GTextFiled;
        private var _getterName2:GTextFiled;
        private var _getterMyDiceNum:GTextFiled;
        private var _btnDetail:GLoadingButton;
        protected var _cellData:WorldBossAllotCellData;

        public function WorldBossAllotCell()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.WorldBossAllotCellBg, 0, 0, this));
            this._selectFilter = UIFactory.bg(-1, 12, 206, 255, this, ImagesConst.MountCardSelectBg);
            this._rewardItemName = UIFactory.gTextField("", 0, 18, 206, 22, this, GlobalStyle.textFormatZi.center().setSize(14));
            this._rewardItem = UIFactory.getUICompoment(MailAttachItem, 74, 76, this);
            this._rewardItem.setSize(60, 60);
            this._needNumText = UIFactory.gTextField("", 0, 150, 206, 22, this, GlobalStyle.textFormatBai.center().setSize(13));
            this._btn = UIFactory.gLoadingButton("", 48, 174, 110, 44, this);
            this._leftTime = UIFactory.secTimeView(Language.getString(21435), 0, 235, 206, 22, this, GlobalStyle.textFormatHuang2.center().setSize(13));
            this._bmpSelected = UIFactory.gImageBitmap(ImagesConst.WorldBossAllotSelected, 72, 175, this);
            this._tipCanChange = UIFactory.gTextField(Language.getString(21436), 0, 202, 206, 22, this, GlobalStyle.textFormatLv.center().setSize(13));
            this._diceLeftTime = UIFactory.secTimeView(Language.getString(21437), 0, 235, 206, 22, this, GlobalStyle.textFormatHuang2.center().setSize(13));
            this._diceState = UIFactory.gTextField(Language.getString(21438), 0, 180, 206, 30, this, GlobalStyle.textFormatHuang2.center().setSize(18));
            this._youSelected = UIFactory.gTextField(Language.getString(21439), 0, 150, 206, 22, this, GlobalStyle.textFormatLv.center().setSize(13));
            this._youAreTheWinner = UIFactory.gTextField("", 0, 160, 206, 60, this, GlobalStyle.textFormatHuang2.center().setSize(16).setLeading(7));
            this._youAreTheWinner.multiline = true;
            this._youAreTheWinner.wordWrap = true;
            this._getterName = UIFactory.gTextField("", 30, 165, 180, 22, this, GlobalStyle.textFormatHuang2.setSize(13));
            this._getterDiceNum = UIFactory.gTextField("", 30, 190, 180, 22, this, GlobalStyle.textFormatHuang2.setSize(13));
            this._getterName2 = UIFactory.gTextField("", 0, 204, 206, 25, this, GlobalStyle.textFormatHuang2.center().setSize(13));
            this._getterMyDiceNum = UIFactory.gTextField("", 0, 233, 206, 25, this, GlobalStyle.textFormatHuang2.setSize(15).center());
            this._btnDetail = UIFactory.gLoadingButton(ResFileConst.SysHistoryDetailBtn, 164, 234, 24, 24, this);
            this._btn.configEventListener(MouseEvent.CLICK, this.onClickBtn);
            this._btnDetail.configEventListener(MouseEvent.CLICK, this.onClickDetail);
            this.setAllVisibleFlase();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._selectFilter.dispose();
            this._selectFilter = null;
            this._rewardItemName.dispose();
            this._rewardItemName = null;
            this._rewardItem.dispose();
            this._rewardItem = null;
            this._needNumText.dispose();
            this._needNumText = null;
            this._btn.dispose();
            this._btn = null;
            this._leftTime.dispose();
            this._leftTime = null;
            this._bmpSelected.dispose();
            this._bmpSelected = null;
            this._tipCanChange.dispose();
            this._tipCanChange = null;
            this._diceLeftTime.dispose();
            this._diceLeftTime = null;
            this._diceState.dispose();
            this._diceState = null;
            this._youSelected.dispose();
            this._youSelected = null;
            this._youAreTheWinner.dispose();
            this._youAreTheWinner = null;
            this._getterName.dispose();
            this._getterName = null;
            this._getterDiceNum.dispose();
            this._getterDiceNum = null;
            this._getterMyDiceNum.dispose();
            this._getterMyDiceNum = null;
            this._btnDetail.dispose();
            this._btnDetail = null;
            this._getterName2.dispose();
            this._getterName2 = null;
            super.disposeImpl();
            return;
        }// end function

        private function setAllVisibleFlase() : void
        {
            this._needNumText.visible = false;
            this._btn.visible = false;
            this._leftTime.visible = false;
            this._bmpSelected.visible = false;
            this._tipCanChange.visible = false;
            this._diceLeftTime.visible = false;
            this._diceState.visible = false;
            this._youSelected.visible = false;
            this._youAreTheWinner.visible = false;
            this._getterName.visible = false;
            this._getterDiceNum.visible = false;
            this._getterMyDiceNum.visible = false;
            this._btnDetail.visible = false;
            this._selectFilter.visible = false;
            this._getterName2.visible = false;
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_3:int = 0;
            super.data = param1;
            this.setAllVisibleFlase();
            var _loc_2:* = param1 as WorldBossAllotCellData;
            if (!_loc_2)
            {
                return;
            }
            this._cellData = _loc_2;
            this._rewardItemName.htmlText = ItemsUtil.getItemName(new ItemData(_loc_2.itemCode), "{0}", true);
            this._rewardItem.itemCode = _loc_2.itemCode;
            if (_loc_2.isSelf)
            {
                this._selectFilter.visible = true;
            }
            if (_loc_2.status == EWorldBossAllotStatus._ESignUp)
            {
                this._needNumText.visible = true;
                this._needNumText.htmlText = Language.getStringByParam(21440, _loc_2.signNum);
                if (!_loc_2.isDiced && !_loc_2.isSelf)
                {
                    this._btn.visible = true;
                    this._btn.enabled = true;
                    this._btn.styleName = ResFileConst.WorldBossBtnNeed;
                    this._btn.drawNow();
                    this._leftTime.visible = true;
                    _loc_3 = 30 - (ClockManager.instance.nowDate.time - this._cellData.startDate.time) / 1000;
                    this._leftTime.setLeftTime(_loc_3);
                }
                else if (!_loc_2.isSelf)
                {
                    this._btn.visible = true;
                    this._btn.styleName = ResFileConst.WorldBossBtnNeed;
                    this._btn.enabled = false;
                    this._btn.drawNow();
                    this._leftTime.visible = true;
                    _loc_3 = 30 - (ClockManager.instance.nowDate.time - this._cellData.startDate.time) / 1000;
                    this._leftTime.setLeftTime(_loc_3);
                }
                else
                {
                    this._getterMyDiceNum.visible = true;
                    this._getterMyDiceNum.htmlText = Language.getStringByParam(21441, _loc_2.selfDiceNum);
                    this._btnDetail.visible = true;
                    this._btnDetail.drawNow();
                    this._bmpSelected.visible = true;
                }
            }
            if (_loc_2.status == EWorldBossAllotStatus._EEnd)
            {
                if (_loc_2.isSelf)
                {
                    this._btnDetail.visible = true;
                    if (_loc_2.getterPlayerName == Cache.instance.role.entityInfo.name)
                    {
                        this._youAreTheWinner.visible = true;
                        this._youAreTheWinner.y = 160;
                        this._youAreTheWinner.htmlText = Language.getString(21442);
                        this._getterMyDiceNum.visible = true;
                        this._getterMyDiceNum.htmlText = Language.getStringByParam(21441, _loc_2.selfDiceNum);
                    }
                    else
                    {
                        this._youAreTheWinner.visible = true;
                        this._youAreTheWinner.y = 150;
                        this._youAreTheWinner.htmlText = Language.getString(21443);
                        this._getterName2.visible = true;
                        this._getterName2.htmlText = Language.getStringByParam(21444, _data.getterPlayerName, _data.getterDiceNum);
                        this._getterMyDiceNum.visible = true;
                        this._getterMyDiceNum.htmlText = Language.getStringByParam(21445, _loc_2.selfDiceNum);
                    }
                }
                else
                {
                    this._getterName.visible = true;
                    this._getterName.htmlText = Language.getStringByParam(21446, _loc_2.getterPlayerName);
                    this._getterDiceNum.visible = true;
                    this._getterDiceNum.htmlText = Language.getStringByParam(21447, _loc_2.getterDiceNum);
                    this._getterMyDiceNum.visible = true;
                    this._getterMyDiceNum.htmlText = Language.getString(21448);
                }
            }
            return;
        }// end function

        protected function onClickBtn(event:MouseEvent) : void
        {
            if (this._cellData)
            {
                if (this._cellData.status == EWorldBossAllotStatus._ESignUp)
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.WorldBossAllotSelectItem, {bossCode:this._cellData.bossCode, itemCode:this._cellData.itemCode}));
                }
            }
            return;
        }// end function

        protected function onClickDetail(event:MouseEvent) : void
        {
            if (this._cellData)
            {
                WorldBossAllotDice.instance.show();
                WorldBossAllotDice.instance.updateData(this._cellData);
            }
            return;
        }// end function

    }
}
